<template>
	<view class="content">
		<u-sticky bgColor="#fff">
			<u-tabs :list="list" :is-scroll="false" style="" :current="current" @change="change"></u-tabs>
		</u-sticky>
		<view v-for="(item,index) in signList" :key="index">
			<u-card :title="item.title" padding="30" margin="26rpx">

				<view class="" slot="body">
					<u-parse class="u-body-item-title u-line-2" :html="'姓名： '+item.studentName"></u-parse>
					<u-parse v-show="item.signInAddress!=null"
						class="u-body-item-title u-line-2">签到地址：{{ item.signInAddress }}</u-parse>
				</view>

				<view slot="foot" style="display: flex;align-items: center;justify-content: space-between;">
					<view v-show="item.signInTime!=null" class="u-body-item-title u-line-2">签到时间：{{ item.signInTime }}
					</view>
				</view>
			</u-card>

		</view>
		<u-modal v-model="show" @confirm="confirm" show-cancel-button :content="content"
			:mask-close-able="true"></u-modal>
	</view>
</template>

<script>
	import {
		getWorkInfoList,
		delWorkJob,
		editWorkJob
	} from '@/api/jz/class/class.js';
	import {
		getAllSign
	} from '@/api/jz/sign/info.js'

	export default {
		data() {
			return {
				timer :"",
				defaultData: {},
				content: "确认要删除吗？",
				list: [{
					name: '已签到',
					count: ""
				}, {
					name: '未签到',
					count: ''
				}],
				current: 0,
				swiperCurrent: 0,
				isAnnounce: null, //0 保存 ； 1 保存并发布
				jobDetailsArr: [], //作业详情
				show: false,
				selId: null,
				signList: [],
				noSignList: []
			}
		},
		mounted() {
			this.change(0)
		},
		methods: {
			change(index) {
				this.current = index;
				switch (index) {
					case 0:
						this.isAnnounce = 0
						break;
					case 1:
						this.isAnnounce = 1
						break;
				}
				let data = {
					isSignIn: this.isAnnounce,
					classId: this.defaultData.classId,
					courseId: this.defaultData.id
				}
				getAllSign(data).then((res) => {
					if (res.code == 200) {
						this.list[0].count = res.data.signList.length + '人'
						this.list[1].count = res.data.noSignList.length + '人'
						if (this.isAnnounce == 0) {
							this.signList = res.data.signList
						} else {
							this.signList = res.data.noSignList
						}
					}
					
				})
				getWorkInfoList({
					isAnnounce: this.isAnnounce
				}).then((res) => {
					if (res.code == 200) {
						this.jobDetailsArr = res.rows

					}
				}).catch((err) => {
					console.error(err);
				});

			},
		},
		onLoad(val) {
			this.defaultData = JSON.parse(decodeURIComponent(val.data));
		},
	}
</script>

<style scoped>
	page {
		height: 100%;
		background-color: #f2f2f2;
	}
</style>
<style scoped lang="scss">
	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32 rpx;
		color: #333;
		padding: 20 rpx 10 rpx;
	}

	.u-body-item image {
		width: 120 rpx;
		flex: 0 0 120 rpx;
		height: 120 rpx;
		border-radius: 8 rpx;
		margin-left: 12 rpx;
	}
</style>